﻿using System.Windows;
using System.Windows.Controls;
using Red.Controls.TimeLine.ViewModels;

namespace Red.Controls.TimeLine.TracksTree
{
    #region BackgroundTemaplateSelector

    public sealed class BackgroundDataTemplateSelector : DataTemplateSelector
    {
        public DataTemplate TracksGroupDataTemplate { get; set; }
        public DataTemplate TrackDataTemplate { get; set; }

        public DataTemplate PointEventDataTemplate { get; set; }
        public DataTemplate DurationDataTemplate { get; set; }
        public DataTemplate TrackItemTemplate { get; set; }

        public override DataTemplate SelectTemplate( object item, DependencyObject container )
        {
            if ( item is TracksGroup )
            {
                return TracksGroupDataTemplate;
            }

            if ( item is Track )
            {
                return TrackDataTemplate;
            }

            if ( item is PointTrackEvent )
            {
                return PointEventDataTemplate;
            }

            if ( item is DurationTrackEvent )
            {
                return DurationDataTemplate;
            }

            return TrackItemTemplate;
        }
    }

    #endregion

    #region BackgroundContainterStyleSelector

    public sealed class BackgroundContainterStyleSelector : StyleSelector
    {
        public Style TracksGroup { get; set; }
        public Style Track { get; set; }
        public Style TrackItem { get; set; }

        public override Style SelectStyle( object item, DependencyObject container )
        {
            if ( item is Track )
            {
                return Track;
            }

            if ( item is TracksGroup )
            {
                return TracksGroup;
            }

            if ( item is TrackItemBase )
            {
                return TrackItem;
            }

          
            return null;
        }
    }

    #endregion

    #region Background

    class TracksBackgroundTree : TreeView
    {
        public TracksBackgroundTree()
        {
        }            
    }

    #endregion
}
